package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysAppVersionMapper;
import com.ruoyi.system.domain.SysAppVersion;
import com.ruoyi.system.service.ISysAppVersionService;

/**
 * app版本Service业务层处理
 *
 * @author ruoyi
 * @date 2024-09-19
 */
@Service
public class SysAppVersionServiceImpl implements ISysAppVersionService {
    @Autowired
    private SysAppVersionMapper sysAppVersionMapper;

    /**
     * 查询app版本
     *
     * @param id app版本主键
     * @return app版本
     */
    @Override
    public SysAppVersion selectSysAppVersionById(Long id) {
        return sysAppVersionMapper.selectSysAppVersionById(id);
    }

    /**
     * 查询app版本列表
     *
     * @param sysAppVersion app版本
     * @return app版本
     */
    @Override
    public List<SysAppVersion> selectSysAppVersionList(SysAppVersion sysAppVersion) {
        return sysAppVersionMapper.selectSysAppVersionList(sysAppVersion);
    }

    /**
     * 新增app版本
     *
     * @param sysAppVersion app版本
     * @return 结果
     */
    @Override
    public int insertSysAppVersion(SysAppVersion sysAppVersion) {
        sysAppVersion.setCreateTime(DateUtils.getNowDate());
        return sysAppVersionMapper.insertSysAppVersion(sysAppVersion);
    }

    /**
     * 修改app版本
     *
     * @param sysAppVersion app版本
     * @return 结果
     */
    @Override
    public int updateSysAppVersion(SysAppVersion sysAppVersion) {
        sysAppVersion.setUpdateTime(DateUtils.getNowDate());
        return sysAppVersionMapper.updateSysAppVersion(sysAppVersion);
    }

    /**
     * 批量删除app版本
     *
     * @param ids 需要删除的app版本主键
     * @return 结果
     */
    @Override
    public int deleteSysAppVersionByIds(Long[] ids) {
        SysAppVersion sysAppVersion = null;
        for (Long id : ids) {
            sysAppVersion = new SysAppVersion();
            sysAppVersion.setId(id);
            sysAppVersion.setDelFlag("1");
            sysAppVersionMapper.updateSysAppVersion(sysAppVersion);
        }
        return ids.length;
    }

    /**
     * 删除app版本信息
     *
     * @param id app版本主键
     * @return 结果
     */
    @Override
    public int deleteSysAppVersionById(Long id) {
        return sysAppVersionMapper.deleteSysAppVersionById(id);
    }
}
